package com.dynamic.data.source.service.impl;

import com.dynamic.data.source.domain.Business;
import com.dynamic.data.source.mapper.BusinessMapper;
import com.dynamic.data.source.service.BusinessService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 开发公司：联信
 * 版权：联信
 * <p>
 * Annotation
 *
 * @author 刘志强
 * @created Create Time: 2021/1/26
 */
@Service
@Slf4j
public class BusinessServiceImpl implements BusinessService {

    @Autowired
    private BusinessMapper businessMapper;

    @Override
    public Business getBusiness(Long id) {
        return businessMapper.getBusiness(id);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Business addBusiness(Business business) {
        businessMapper.addBusiness(business);
        // 报错测试回滚
        int[] i = {};
        log.info(String.valueOf(i[2]));
        return business;
    }
}
